package com.lin.controller;

import com.lin.annotation.MyLog;
import com.lin.pojo.Store;
import com.lin.services.StoreService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * ClassName    StoreController
 * Package      com.lin.controller
 *
 * @author hellcat
 * Date         2020/2/24
 * Description: 超市信息
 * 🐾
 */
@Controller
@RequestMapping("store")
public class StoreController {
    @Autowired
    private StoreService storeService;

//    @MyLog("查询超市信息")
    @RequestMapping(value = "/toStore", method = RequestMethod.GET)
    public String toStore(HttpServletRequest request) {
        request.setAttribute("ddId", "Store");
        Store store = storeService.getStoreInfoById();
        request.setAttribute("storeInfo", store);
        return "storeMain";
    }

    @RequestMapping(value = "/listArea", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> listArea(HttpServletRequest request) {
        return storeService.listArea();
    }

    @MyLog("更新超市信息")
    @RequiresPermissions("store:updateStore")
    @RequestMapping(value = "/updateStore", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> updateStore(Store store) {
        return storeService.updateStore(store);
    }

    @RequiresPermissions("store:haveNoStore")
    @RequestMapping(value = "/insertStore", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> insertStore(Store store) {
        return storeService.insertStore(store);
    }

}
